import { Redirect } from 'umi';
import React, { PureComponent } from 'react';
import { connect } from '@@/plugin-dva/exports';
// @ts-ignore
@connect(({ global }) => ({ global }))
export default class Index extends PureComponent{
  getRoute(params: string| null) {
    // @ts-ignore
    this.props.dispatch({
      type: 'global/getRoute',
      id: params
    })
  }

  componentWillMount(): void {
    // 从 url 获取参数
    // @ts-ignore
    const { routeId, openId } = this.props.location.query;
    if (routeId && openId) {
      localStorage.setItem('openId', openId);
      localStorage.setItem('routeId', routeId);
    }
    this.getRoute(localStorage.getItem('routeId'));
  }

  render():any {
    return (
      <Redirect to={{ pathname: '/home', state: {} }}
      />
  );
  }
}
